home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctjjl86.arc / OPTXOR.ASM < prev    next >
Assembly Source File  |  1986-04-16  |  2KB  |  65 lines

  1. ; *** Listing 5 ***
  2. ;
  3. ;Optimized XOR graphics driver for putting rectangular images into
  4. ; the Color/Graphics Adapter's medium-resolution memory map.
  5. ;
  6. ; Note: AX,BX,CX,DX,BP,SI,DI destroyed.
  7. ;
  8. one    segment para public 'CODE'
  9.     assume    cs:one,ds:one,es:nothing
  10.     public    form_driver
  11. ;
  12. form_driver proc near
  13.     mov    di,[bx+even_line_screen_offset_table]  ;find offset of
  14.                            ; top line of image
  15.     add    di,cx     ;ES:DI now points to byte at which to put
  16.              ; the image's upper left corner
  17.     lodsb         ;get the height of the image
  18.     shr    al,1     ;divide by 2 to arrive at number of even/odd
  19.              ; line pairs in the image
  20.     mov    ah,al     ;store count in AH
  21.     lodsb         ;get the width of the image in bytes
  22.     mov    bl,al     ;put width in BL
  23.     sub    bh,bh     ;make width a 16 bit value
  24.     mov    bp,2000h ;calculate the amount to add after even scan
  25.     sub    bp,bx     ; lines are drawn to get to address of the
  26.              ; next scan line
  27.     mov    dx,1fb0h ;calculate amount to subtract after odd scan
  28.     add    dx,bx     ; lines are drawn to get to address of the
  29.              ; next scan line
  30. ;
  31. next_two_lines:
  32.     mov    cx,bx       ;set the number of bytes/line for the form
  33. next_column_for_even_row:
  34.     lodsb           ;get the next image byte
  35.     xor    es:[di],al ;exclusive-OR it into screen memory
  36.     inc    di       ;point to next screen memory position
  37.     loop    next_column_for_even_row   ;loop for next byte 
  38.                        ; on even line
  39.     add    di,bp  ;calculate address to start next line of image
  40.     mov    cx,bx  ;reset the number of bytes/line for an odd row
  41. next_column_for_odd_row:
  42.     lodsb           ;get the next image byte from the form
  43.     xor    es:[di],al ;exclusive-OR onto screen
  44.     inc    di       ;advance screen memory pointer
  45.     loop    next_column_for_odd_row ;loop for nxt byte on odd line
  46.     sub    di,dx       ;calculate the address to start next line 
  47.                ; of image--next line will be an even line
  48.     dec    ah           ;count down number of line pairs
  49.     jne    next_two_lines ; jmp if any even/odd line pairs left
  50.     ret               ; if not, return to calling program
  51. ;
  52. ;This table is used to find the offset of an even scan line in
  53. ; the memory map of the color graphics adapter in medium res mode.
  54. ;
  55. even_line_screen_offset_table label word
  56. x=0
  57.     rept    100    ;there are 100 even lines
  58.     dw    x*50h    ; each is 50h (80 decimal) long
  59. x=x+1
  60.     endm
  61. ;
  62. form_driver endp
  63. one    ends
  64.     end
  65.